import { data } from 'jquery';
import service from '../utils/request';  // 导入已配置的 axios 实例
// ✅ 导出 service 实例
export const http = service;
const api = {
    service,
    userLogin(query) {
        return service.get('/user/login', { params: query });
    },
    logout(query) {
        return service.get('/user/logout', { params: query });
    },
    signIn(data) {
        return service.post('/user/sign-in', data);
    },
    getUserInfo(query) {
        return service.get('/user/info', { params: query });
    },
    sendCode(data)
    {
        return service.post('/user/send-code', data);
    },
    resetPassword(data) {
        return service.post('/user/reset-password', data);
    },
    updateUserPublicInfo(data) {
        return service.post('/user/info', data);
    },
    updatePassword(query) {
        return service.get('/user/password', { params: query });
    },
    NowPosition(query){
        return service.get('/address/getAddressByBaidu', { params: query });
    },
    getAddressDetails(query) {
        return service.get('/address/getAddressDetails', { params: query });
    },
    addAddress(data) {
        return service.post('/address/add', data);
    },
    getAddress(query) {
        return service.get('/address/info', { params: query });
    },
    updateAddress(data) {
        return service.post('/address/update', data);
    },
    deleteAddress(data) {
        return service.post('/address/delete', data);
    },
    addIdleItem(data) {
        return service.post('/idle/add', data);
    },
    getIdleItem(query) {
        return service.get('/idle/info', { params: query });
    },
    // 热门闲置物品查询
    findHotIdleItems(query)
    {
        return service.get('/idle/hot', { params: query });
    },
    getAllIdleItem(query) {
        return service.get('/idle/all', { params: query });
    },
    IdleItemSortByPrice(query)
    {
        return service.get('/idle/sortByPrice', { params: query });
    },
    findIdleItem(query) {
        return service.get('/idle/find', { params: query });
    },
    findIdleItemByHot(query)
    {
        return service.get('/idle/findByHot', { params: query });
    },
    findIdleItemByPrice(query) {
        return service.get('/idle/findByPrice', { params: query });
    },
    findIdleItemByMix(query) {
        return service.get('/idle/findByMix', { params: query });
    },
    findIdleItemByLabel(query) {
        return service.get('/idle/lable', { params: query });
    },
    updateIdleItem(data) {
        return service.post('/idle/update', data);
    },
    addOrder(data) {
        return service.post('/order/add', data);
    },
    getOrder(query) {
        return service.get('/order/info', { params: query });
    },
    updateOrder(data) {
        return service.post('/order/update', data);
    },
    processRefund(data)
    {
        return service.post('/alipay/refund',data);
    },
    getMyOrder(query) {
        return service.get('/order/my', { params: query });
    },
    getMySoldIdle(query) {
        return service.get('/order/my-sold', { params: query });
    },
    reqAliPay(data)
    {
        return service.post('/alipay/pay',data);
    },
    addOrderAddress(data) {
        return service.post('/order-address/add', data);
    },
    updateOrderAddress(data) {
        return service.post('/order-address/update', data);
    },
    getOrderAddress(query) {
        return service.get('/order-address/info', { params: query });
    },
    addFavorite(data) {
        return service.post('/favorite/add', data);
    },
    getMyFavorite(query) {
        return service.get('/favorite/my', { params: query });
    },
    deleteFavorite(query) {
        return service.get('/favorite/delete', { params: query });
    },
    checkFavorite(query) {
        return service.get('/favorite/check', { params: query });
    },
    sendMessage(data) {
        return service.post('/message/send', data);
    },
    getMessage(query) {
        return service.get('/message/info', { params: query });
    },
    getAllIdleMessage(query) {
        return service.get('/message/idle', { params: query });
    },
    getAllMyMessage(query) {
        return service.get('/message/my', { params: query });
    },
    deleteMessage(query) {
        return service.get('/message/delete', { params: query });
    },
    getMessageDetail(query) {
        return service.get('/chat/messages', { params: query });
    },
    getUnreadMessageCount(query) {
        return service.get('/message/unread-count',{params:query})
    },
    markMessagesAsRead(data) {
        return service.post('/message/mark-read',data)
    },
    getGoods(query) {
        return service.get('/admin/idleList', { params: query });
    },
    updateGoods(query) {
        return service.get('/admin/updateIdleStatus', { params: query });
    },
    getOrderList(query) {
        return service.get('/admin/orderList', { params: query });
    },
    deleteOrder(query) {
        return service.get('/admin/deleteOrder', { params: query });
    },
    getUserData(query) {
        return service.get('/admin/userList', { params: query });
    },
    getUserManage(query) {
        return service.get('/admin/list', { params: query });
    },
    updateUserStatus(query){
        return service.get('/admin/updateUserStatus', { params: query });
    },
    regAdministrator(data){
        return service.post('/admin/add', data);
    },
    adminLogin(query) {
        return service.get('/admin/login', { params: query });
    },
    getChartsInfo(query) {
        return service.get('/admin/getChartsData', { params: query });
    },
    deleteAdmin(data)
    {
        return service.post('/admin/deleteAdmin', data);
    },
    getCurrentAdmin(query)
    {
        return service.get('/admin/getCurrentAdmin', { params: query });
    },
    loginOut(query) {
        return service.get('/admin/loginOut', { params: query });
    },
    exportReport(params) {
        return service({
          url: '/admin/exportReport',
          method: 'get',
          params: params,
          responseType: 'blob', // 确保指定响应类型
          headers: {
            'Authorization': 'Bearer ' + localStorage.getItem('token')
          }
        })
      }
};

export default api;